

//导入请求工具类
import request from '@/utils/request.js'

import {useTokenStore} from '@/stores/token.js'


/**
 * 获取文章分类列表的服务函数
 * 
 * 该函数通过发送HTTP GET请求从服务器获取文章的分类信息
 * 主要用于前端界面展示文章分类，便于用户浏览和选择
 * 
 * @returns {Promise} 返回一个Promise对象，该对象在解析后包含分类信息的数据
 */
export const articleCategoryListService = () => {

    //获取token状态
    //const tokenStore = useTokenStore()
    //通过请求头Authorization携带token
    return request.get('/category')
}

//添加文章分类
export const articleCategoryAddService = (categoryData) => {
    return request.post('/category', categoryData)
}

//修改分类
export const articleCategoryUpdateService = (categoryData)=>{
    return request.put('/category',categoryData)
}

//删除分类
export const articleCategoryDeleteService = (id) => {
    return request.delete('/category?id='+id)
}


//获取文章列表
export const articleListService = (params) => {
    return request.get('/article',{params:params})
}

//添加文章
export const articleAddService = (articleData) => {
    return request.post('/article',articleData)
}

//删除文章
export const articleDeleteService = (id) => {
    return request.delete('/article?id='+id)
}

//修改文章
export const articleUpdateService = (articleData) => {
    return request.put('/article',articleData)
}
